<script>
	export default {
		globalData: {  
			supportMode: [],
		},
		onLaunch: function() {
			console.warn('当前组件仅支持 uni_modules 目录结构 ，请升级 HBuilderX 到 3.1.0 版本以上！')
			console.log('App Launch')
			// #ifdef MP-WEIXIN
			this.getBioAuthentication()
			// #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			getBioAuthentication() {
				const _this = this
				uni.checkIsSupportSoterAuthentication({
					success(res) {
						if(res.errMsg === 'checkIsSupportSoterAuthentication:ok') {
							_this.$store.dispatch('user/setBio', {supportMode: res.supportMode})
							res.supportMode.forEach((item, index) => {
								_this.getBioEnrolled(item)
							})
						}
					},
					fail(err) {
						console.log(err)
					},
					complete(res) {
						console.log(res)
					}
				})
			},
			getBioEnrolled(e) {
				const _this = this
				uni.checkIsSoterEnrolledInDevice({
					checkAuthMode: e,
					success(res) {
						if(res.errMsg === 'checkIsSoterEnrolledInDevice:ok') {
							const data = {}
							data['bio_' + e] = res.isEnrolled
							_this.$store.dispatch('user/setBio', data)
						}
					},
					fail(err) {
						console.log(err)
					},
					complete(res) {
						console.log(res)
					}
				})
			},
		},
	}
</script>

<style>
	/*每个页面公共css */
	@import 'static/style/common.css';
	@import 'static/style/iconfont.css';
	@import 'static/style/constellation.css';
	/* @import 'static/style/colorui.css'; */
</style>
